Note: This tutorial assumes that you have completed the previous tutorials: A more advanced Publisher and Subscriber.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Using Tabpage Handlers (Diagnostics)

Description: How to use pre-built tabpage handlers in the ROSOSC stack. In particular, the diagnostics tabpage handler.

Tutorial Level: BEGINNER

Up until now, we have just explored the default tabpage handler in the ROSOSC stack. To realize the full potential of the ROSOSC stack, we can begin to use tabpage "handlers" that are included in the stack.

Tabpage Handler

A tabpage handler is a Python class designed to subscribe and publish to ROS topics based on user interaction with the TouchOSC app. Using a handler, you no longer have to interact via the ROS Publisher/Subscriber interface, but can get a direct hook into the workings of the OSC and ROS protocols.

The advantage of this is that you get a plugin architecture for creating and using pre-built handlers that dictate specific behavior of the touchosc_bridge.

Setting up a launch file for Handlers

We are going to build upon the launch files that we have used in the earlier tutorials to show the ease of adding a pre-built handler to your project.

To begin with, let's create a new launch file.

<launch>
    <node pkg="diagnostic_aggregator" type="aggregator_node" name="diagnostic_aggregator" output="screen">
        <rosparam command="load" file="$(find rososc_tutorials)/07diagnostics/aggregator.yaml"/>
    </node>
    <node pkg="rososc_tutorials" type="dummydiagnosticsnode.py" name="dummydiagnostics"/>

    <node pkg="touchosc_bridge" type="touchosc_bridge.py" name="touchosc_bridge" output="screen">
        <param name="osc_name" value="ROS Diagnostics"/>
        <param name="port" value="10000" />
        <param name="print_fallback" value="False"/>
        <param name="load_default" value="False"/>
        <rosparam param="handlers">[diagnostics]</rosparam>
        <rosparam command="load" file="$(find rososc_tutorials)/07diagnostics/diagnostics.yaml" />
    </node>

    <param name="layout_path" value="$(find diagnostics_handler)/layouts" />            
    <rosparam param="layouts">
        [ "diag-ipad-vertical.touchosc", "diag-ipod-vertical.touchosc" ]
    </rosparam>   
    <node pkg="pytouchosc" type="layoutserver_node" name="layoutserver"/>
</launch>

Notice that in addition to our previously specified paramaters, we have added two new ones. The first handlers specifies which handlers that the touchosc_bridge node needs to look for. The second loads a YAML file with configuration parameters for that specific handler. The diagnostics.yaml file looks like this.

# Handler specific information
diagnostics:
  # Required parameters
  pkg: diagnostics_handler
  class: 'diagnosticstabpage/DiagnosticsTabpageHandler'
  tabpage_aliases: [] 

  start_topic: '/diagnostics'

Handler Configuration File

The touchosc_bridge node reads in ROS parameters that are loaded with the rosparam command.

The launch file holds a handlers parameter that lists the configuration subsections for the node to look for. Note how the root configuration directive of the YAML file matches the name of the handler provided in the handlers parameter. This is also the base tabpage name that will be used for the handler.

Each handler must have a few parameters set in order to function properly.

pkg

  • The ROS package where the handler may be found.

class

  • In this example, the DiagnosticsTabpageHandler class is in the diagnosticstabpage.py file in the diagnostics_handler/src/diagnostics_handler directory. While it is not necessary to follow this directory structure exactly, it prevents potential namespace clashes in Python.

tabpage_aliases

  • These are the other names that will be mapped to the same tabpage handler. In this example, two hardware-specific TouchOSC layouts are used, but they both interact with the same tabpage handler.

The other parameters are handler-specific, in this case, the parameter is used to set the initial topic that all new clients will subscribe to.

Starting the Node

Once you have created the launch and YAML files, you can simply start the node with roslaunch

roslaunch rososc_tutorials diagnostics.launch

Try interacting a bit with the diagnostics node. If you have used the launch file included with the tutorial, some sample diagnostics data will be published, in addition to the TouchOSC diagnostics data (each tabpage handler has the capability to publish diagnostics data).

Some things to note:

  • Pressing the button in the lower left ("/diagnostics" or "/diagnostics_agg") will cause the subscribed topic to change.

Viewing the raw diagnostics data Viewing the aggregated diagnostics data

  • You can use the up and down buttons next to the list of diagnostics topics to scroll the list, or you can use the scrollbar to "jump" to a place in the list.
  • Clicking on a diagnostics topic will bring up more detailed information for that topic.

Expanded diagnostics information

  • In diagnostics_agg mode, double clicking on a higher level topic will expand that topic. Double click on the topic again to go back up a level.

Wiki: rososc_tutorials/Tutorials/Using Tabpage Handlers (Diagnostics) (last edited 2011-12-20 05:12:30 by MichaelCarroll)